package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.LkyDocumentTableManage;

public class LkyDocumentTableManageUpdateValidator extends Validator {

    @Override
    protected void validate(Controller c) {

        LkyDocumentTableManage lkyDocumentTableManage = c.getModel(LkyDocumentTableManage.class, "lkyDocumentTableManage");

        if(lkyDocumentTableManage.get("file_name") != null)
            validateString("lkyDocumentTableManage.file_name", 0, 20, "msg", "文件名 最多20个字符");
        validateRequired("lkyDocumentTableManage.file_name", "msg", "请输入文件名");
        if(lkyDocumentTableManage.get("period") != null)
            validateString("lkyDocumentTableManage.period", 0, 1, "msg", "周期(天1周2月3期4年5) 最多1个字符");
        validateRequired("lkyDocumentTableManage.period", "msg", "请输入周期(天1周2月3期4年5)");
        validateRequired("lkyDocumentTableManage.times", "msg", "请输入需填次数");
        validateRequired("lkyDocumentTableManage.table_type", "msg", "请输入表类型");

        if(lkyDocumentTableManage.get("start_time") != null)
            validateDate("lkyDocumentTableManage.start_time", "msg", "开始时间: "+lkyDocumentTableManage.get("lkyDocumentTableManage.start_time")+" 格式错误");
        validateRequired("lkyDocumentTableManage.start_time", "msg", "请输入开始时间");

        if(lkyDocumentTableManage.get("end_time") != null)
            validateDate("lkyDocumentTableManage.end_time", "msg", "结束时间: "+lkyDocumentTableManage.get("lkyDocumentTableManage.end_time")+" 格式错误");
        validateRequired("lkyDocumentTableManage.end_time", "msg", "请输入结束时间");

    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }

}